package com.googlecode.continuity.core.client;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.RootPanel;

/**
 * GWTExternal is a singleton providing GWT code with several methods to interact with (external) Javascript on the host
 * page. It is used in the injecting process of {@link com.googlecode.continuity.core.client.UIEntryPoint} but can alsoe
 * provide more general access to data or functionality in the host page.
 *
 * @author Peter Schmitt <aragos@aragos.de>
 */
public class GWTExternal {
  /**
   * Returns a string representing a property set on the host page.
   * @param propertyName identifying name of the property
   * @return property value
   */
  public static native String getProperty(String propertyName) /*-{
    return $wnd.GWTExternal.getProperty(propertyName);
  }-*/;

  /**
   * Returns true if the requested {@link com.googlecode.continuity.core.client.UIEntryPoint} is enabled on the host
   * page.  The string used for this check is the fully qualified type name of the <code>UIEntryPoint</code>.
   *
   * @param entryPoint fully qualified type name of the <code>UIEntryPoint</code> to be checked
   * @return true if the <code>UIEntryPoint</code> is enabled on the host page, false otherwise
   */
  public static native boolean isEntryPointEnabled(String entryPoint) /*-{
    return $wnd.GWTExternal.isEntryPointEnabled(entryPoint);
  }-*/;
}
